package output;

import java.io.*;

public class Serial {

	public static boolean write(String filename, Serializable object) {
		if (object == null)
			return false;
		FileOutputStream fos = null;
		ObjectOutputStream out = null;
		try {
			fos = new FileOutputStream(filename);
			out = new ObjectOutputStream(fos);
			out.writeObject(object);
			out.close();
			return true;
		} catch (IOException ex) {
		}
		return false;
	}

	public static Object read(String filename) {
		if (filename == null)
			return null;
		Object object = null;
		FileInputStream fis = null;
		ObjectInputStream in = null;
		try {
			fis = new FileInputStream(filename);
			in = new ObjectInputStream(fis);
			object = in.readObject();
			in.close();
		} catch (IOException ex) {
			ex.printStackTrace();
		} catch (ClassNotFoundException ex) {
			ex.printStackTrace();
		}
		return object;
	}

}